<template>
  <a-spin :spinning="loading">
    <div style="margin-bottom: 20px" v-if="detailList && detailList.length > 0">
      <div style="font-size: 16px;font-weight: 600;margin-bottom: 10px;">订单明细</div>
      <a-table class="expandSku" :customHeaderRow="customHeaderRow" :pagination="false" bordered  :dataSource="detailList" :columns="orderDetailColumns"/>
    </div>
  </a-spin>
</template>
<script setup>
import { ref, defineProps, defineExpose } from 'vue'
import {getInventoryDetail, getSkuPoolList} from "@/api/inventoryPools/skuPool.js";
import {message} from "ant-design-vue";
import {getFoShanSku} from "@/api/inventoryPools/foShan.js";
const props = defineProps({
  id:{
    type:String,
    default:''
  },
  productSku:{
    type:String,
  },
  poolCode:{
    type:String,
  },
  warehouseCode:{
    type:String,
  },
})
const loading = ref(false)
const orderDetailColumns = [
  {
    title: '平台',
    dataIndex: 'platform',
    key: 'platform',
    align: 'center'
  },
  {
    title: '平台订单',
    dataIndex: 'orderId',
    key: 'orderId',
    align: 'center'
  },
  {
    title: '易仓订单',
    dataIndex: 'saleOrderCode',
    key: 'saleOrderCode',
    align: 'center'
  },
  {
    title: '下单时间',
    dataIndex: 'orderCreateTime',
    key: 'orderCreateTime',
    align: 'center'
  },
  {
    title: '平台SKU',
    dataIndex: 'productSku',
    key: 'productSku',
    align: 'center'
  },
  {
    title: '仓库SKU',
    dataIndex: 'warehouseSku',
    key: 'warehouseSku',
    align: 'center'
  },
  {
    title: '数量',
    dataIndex: 'qty',
    key: 'qty',
    align: 'center'
  },
  {
    title: '交期',
    dataIndex: 'evaDelivery',
    key: 'evaDelivery',
    align: 'center'
  },
  {
    title: '最迟标发',
    dataIndex: 'latestSendout',
    key: 'latestSendout',
    align: 'center'
  },
  {
    title: '易仓版本',
    dataIndex: 'sourceVersion',
    key: 'sourceVersion',
    align: 'center'
  },
  {
    title: '计算版本',
    dataIndex: 'chVerion',
    key: 'chVerion',
    align: 'center'
  },
  {
    title: '延迟发货',
    dataIndex: 'delayFor',
    key: 'delayFor',
    align: 'center'
  },
  {
    title: '占用类型',
    dataIndex: 'isSpare',
    key: 'isSpare',
    align: 'center',
    scopedSlots: { customRender: 'isSpare' }
  }
]
const detailList = ref([])
const skuDetailList = ref([])
const init = async () => {
  try{
    loading.value = true
    const res1 = await getFoShanSku({
      sku: props.productSku,
    })
    detailList.value = res1.result.records
  }catch (e){
    message.error(e)
  }finally{
    loading.value = false
  }
}
const customHeaderRow = (column, index) => {
  return {
    class: "header-row",
  };
};
defineExpose({
  init
})
</script>

<style lang="less">
.expandSku {
  .header-row > th {
    background-color: #6593d5!important;
  }
}
</style>
